<?php
// 从URL中获取sense_name参数的值
$sense_name = $_GET['sense_name'];


// 连接数据库
include('connection.php');
session_start();
$userid = $_SESSION['userid'];
$sql = "SELECT userid FROM user WHERE userid = '$userid';";
$result = mysqli_query($connection, $sql);
if (!$result) {
    die("查询失败");
}
// 获取查询结果中的第一行数据，即user_id为1的记录的user_id
$row = mysqli_fetch_assoc($result);

$sql = "DELETE FROM schedule WHERE userid = $userid AND sense_name = '$sense_name';";
$result = mysqli_query($connection, $sql);
if (!$result) {
// 关闭数据库连接
    mysqli_close($connection);
    ?>
    <script>
        alert("删除失败");
        history.back();
    </script>
    <?php
} else {
    // 关闭数据库连接
    mysqli_close($connection);
    ?>
    <script>
        alert("删除成功");
        history.back();
    </script>
    <?php }
?> 